package com.cman777.springc.redis.bean.dto;

import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * @author chenzhicong
 * @time 2019/11/10 16:02
 * @description
 */
@Getter
@Setter
public class RedisLockInfo  implements Serializable {
    /**
     * redis的锁的key
     */
    @NotBlank
    private String key;

    /**
     * 等待时间，单位秒
     */
    private long waitTime;

    /**
     * 锁的自动释放时间，单位秒
     */
    private long leaseTime;

    @Override
    public int hashCode() {
        return this.key.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (null == obj) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof RedisLockInfo)) {
            return false;
        }
        RedisLockInfo RedisLockInfo = (RedisLockInfo)obj;
        return this.key.equals(RedisLockInfo.getKey());
    }
}
